<!--
 * @Description: file content
 * @Author: Zt2tzzt
 * @Date: 2021-09-18 09:37:33
 * @LastEditors: Zt2tzzt
 * @LastEditTime: 2021-09-18 09:43:29
 * @LastEditContent: 
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app"></div>

  <template id="my-app">
    <button @click="changeFirstname">修改firstname</button>

    <h2>{{ fullname }}</h2>
    <h2>{{ fullname }}</h2>
    <h2>{{ fullname }}</h2>
    
    <h2>{{ getFullname() }}</h2>
    <h2>{{ getFullname() }}</h2>
    <h2>{{ getFullname() }}</h2>
  </template>

  <script src="https://unpkg.com/vue@next"></script>
  <script>
    const app = {
      template: '#my-app',
      data() {
        return {
          firstname: 'lionel',
          lastname: 'messi'
        }
      },
      watch: {
        
      },
      computed: {
        fullname() {
          console.log('computed 的 fullname 中的计算')
          return this.firstname + ' ' + this.lastname
        }
      },
      methods: {
        getFullname() {
          console.log('methods 的 getFullname 中的计算')
          return this.firstname + ' ' + this.lastname
        },
        changeFirstname() {
          this.firstname = 'Coder'
        }
      }
    }
    Vue.createApp(app).mount('#app')
  </script>
</body>
</html>